package com.ruoyi.web.controller.screen;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.system.domain.*;
import com.ruoyi.system.service.ProjectsService;
import com.ruoyi.system.service.ScreenService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

//大屏统计图
@RestController
@RequestMapping("/system/screen")
public class ScreenController extends BaseController {

    @Autowired
    private ProjectsService projectsService;

    @Autowired
    private ScreenService screenService;
    //实际投资与计划投资
    @PostMapping("/invest")
    public TableDataInfo list(Invest invest,@RequestHeader("userId") String userId)
    {
        invest.setUserId(userId);
        List<Invest> list = screenService.selectInvest(invest);
        return getDataTable(list);
    }

    //返回地图上所有的点
    @PostMapping("/getCoordinate")
    public List<Coordinate> getCoordinate(Projects projects,@RequestHeader("userId")String userId)
    {
       projects.setUserId(userId);
       List<Coordinate> list=screenService.getCoordinate(projects);
       return list;

    }

    @PostMapping("/industry")
    public Map industry(String mouYear)
    {
        Map<String ,Object> map= screenService.selectIndustry(mouYear);
        return map;
    }
    @PostMapping("/area")
    public Map area(String disType, String mouYear,@RequestHeader("userId") String userId)
    {

        Map<String ,Object> map= screenService.selectArea(disType,mouYear,userId);
        return map;
    }
    @PostMapping("/DomesticContent")//大屏标点内容
    public AjaxResult selectDomesticContent(Coordinate coordinate)
    {
        return AjaxResult.success(projectsService.selectDomesticContent(coordinate.getProLongitude(),coordinate.getProDimensionality()));
    }
    @GetMapping("/issue")
    public TableDataInfo area(ProjectIssue projectIssue,@RequestHeader("userId")Long userId)
    {
        //根据部门Id查询
        int deptId = projectsService.selectDept(String.valueOf(userId));
        //判断是否为admin
        if (deptId!=-1) {
            if (0 == projectsService.selectDeptId(userId+"")) {
                projectIssue.setDeptId(-1);
            } else {
                projectIssue.setDeptId(deptId);
            }
        }
        startPage();
        List<ProjectIssue> projectIssues = screenService.queryIssue(projectIssue);
        return getDataTable(projectIssues);
    }
    @PostMapping("/list")
    public Map list(@RequestHeader("userId")String userId)
    {
        return  screenService.queryList(userId);
    }

}
